#include "main.h"

cr_state *state;

int main(int argc, char **argv) {
    /* start SDL */
    uint32_t flags = SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS;
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        fprintf(stderr, "SDL_Init error: %s\n", SDL_GetError());
        return 1;
    }

    /* init from init.c (graphics + game logic) */
    state = init();

    /* when program exits, execute cleanup */
    atexit(cleanup);

    int quit = 0;
    while (!quit) {
        pre_render(&state->renderer, &state->display);
        update_crg(state);
        update_render(&state->renderer, &state->display, &state->render_change);
        get_input(state->root);
        /* set to around 60fps (1000 ms/ 60 fps = 1/16 ms^2/frame) */
        SDL_Delay(16);
    }

    return 0;
}